<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/jquery-layout/jquery.layout-latest.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css}" rel="stylesheet"/>
<body class="gray-bg">


	<div class="ui-layout-west">
		<div class="main-content">
			<div class="box box-main">
				<div class="box-header">
					<div class="box-title">
						<i class="fa icon-grid"></i> 项目版本
					</div>
					<div class="box-tools pull-right">
						<a type="button" class="btn btn-box-tool menuItem" href="#" onclick="toProjectVersion()" title="管理项目版本"><i class="fa fa-edit"></i></a>
						<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i class="fa fa-chevron-up"></i></button>
						<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i class="fa fa-chevron-down"></i></button>
						<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新项目版本"><i class="fa fa-refresh"></i></button>
					</div>
				</div>
				<div class="ui-layout-content">
					<div id="tree" class="ztree"></div>
				</div>
			</div>
		</div>
	</div>
     <div class="container-div ui-layout-center">
		 <form class="form-horizontal" id="product-version-setting-form" data-config-type="dorcst-330">
			 <div class="panel-form">
				 <div class="panel-head">
					 <h3>数据库配置</h3>
				 </div>
				 <div class="panel-content cancel-top-padding">
					 <fieldset>
						 <legend style="font-size: 16px;">MySQL</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">IP</label>
									 <div class="col-md-8">
										 <input type="text" name="server.mysql.host" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">端口</label>
									 <div class="col-md-8">
										 <input type="text" name="server.mysql.port" class="form-control" value="3306">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">用户名</label>
									 <div class="col-md-8">
										 <input type="text" name="server.mysql.db.username" class="form-control" value="root">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">密码</label>
									 <div class="col-md-8">
										 <input type="password" name="server.mysql.db.password" class="form-control origin-input">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">数据库名</label>
									 <div class="col-md-8">
										 <input type="text" name="server.mysql.dbname" class="form-control" value="dorcst">
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>
					 <fieldset>
						 <legend style="font-size: 16px;">Redis</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">IP</label>
									 <div class="col-md-8">
										 <input type="text" name="server.redis.host" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">端口</label>
									 <div class="col-md-8">
										 <input type="text" name="server.redis.port" class="form-control" value="6379">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">密码</label>
									 <div class="col-md-8">
										 <input type="password" name="server.redis.password" class="form-control origin-input">
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>
				 </div>
			 </div>

			 <div class="panel-form">
				 <div class="panel-head">
					 <h3>应用服务器配置</h3>
				 </div>
				 <div class="panel-content cancel-top-padding">
					 <fieldset>
						 <legend style="font-size: 16px;">前端应用服务</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">外网访问协议</label>
									 <div class="col-md-8">
										 <input type="text" name="apache.extranet.protocol" class="form-control" value="http">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">host</label>
									 <div class="col-md-8">
										 <input type="text" name="apache.extranet.host" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">端口</label>
									 <div class="col-md-8">
										 <input type="text" name="apache.extranet.port" class="form-control" value="80">
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>
					 <fieldset>
						 <legend style="font-size: 16px;">后端应用服务</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">host</label>
									 <div class="col-md-8">
										 <input type="text" name="dorcst.api.ip" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">端口</label>
									 <div class="col-md-8">
										 <input type="text" name="dorcst.api.port" class="form-control" value="8086">
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>
					 <fieldset>
						 <legend style="font-size: 16px;">同步服务</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">host</label>
									 <div class="col-md-8">
										 <input type="text" name="dorcst.sync.host" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">端口</label>
									 <div class="col-md-8">
										 <input type="text" name="dorcst.sync.port" class="form-control" value="8080">
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>
					 <fieldset>
						 <legend style="font-size: 16px;">会诊(好视通)服务配置</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">客户标识</label>
									 <div class="col-md-8">
										 <select class="form-control" name="meeting.client">
											 <option value="hstpri">私有云</option>
											 <option value="hstpub">公有云</option>
										 </select>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">访问地址</label>
									 <div class="col-md-8">
										 <input type="text" name="meeting.domain" class="form-control">
										 <span class="help-block">会诊访问地址，如：http://192.168.0.217:8080/</span>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">wsdl访问地址</label>
									 <div class="col-md-8">
										 <input type="text" name="meeting.wsUrl" class="form-control">
										 <span class="help-block">web服务访问地址，如：http://192.168.0.217:8080/fmapi/webservice/jaxws?wsdl</span>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">发起人密码</label>
									 <div class="col-md-8">
										 <input type="text" name="meeting.password" class="form-control" value="Abc123456">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">管理员账号</label>
									 <div class="col-md-8">
										 <input type="text" name="meeting.rootName" class="form-control" value="中智达信1">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">管理员密码</label>
									 <div class="col-md-8">
										 <input type="text" name="meeting.rootPWD" class="form-control" value="123456">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">keyCode</label>
									 <div class="col-md-8">
										 <input type="text" name="meeting.keyCode" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">最大用户数</label>
									 <div class="col-md-8">
										 <input type="text" name="meeting.maxUserCount" class="form-control" value="20">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">验证模式</label>
									 <div class="col-md-8">
										 <select class="form-control" name="meeting.verifyMode">
											 <option value="1">用户密码验证</option>
											 <option value="2">会议室密码验证</option>
											 <option value="3">匿名登录</option>
											 <option value="4">注册用户登录</option>
										 </select>
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>

					 <fieldset>
						 <legend style="font-size: 16px;">影像服务配置</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">ftp地址</label>
									 <div class="col-md-8">
										 <input type="text" name="image.hospital.ftp.address" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">ftp端口</label>
									 <div class="col-md-8">
										 <input type="text" name="image.hospital.ftp.port" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">ftp用户名</label>
									 <div class="col-md-8">
										 <input type="text" name="image.hospital.ftp.username" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">ftp密码</label>
									 <div class="col-md-8">
										 <input type="text" name="image.hospital.ftp.password" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">服务器目录</label>
									 <div class="col-md-8">
										 <input type="text" name="image.myftp.shared.path" class="form-control">
										 <span class="help-block">ftp挂载到项目部署的服务器目录，如：\\\\192.168.0.210\\dicomdata或本地D:/dicomdata</span>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">联氪地址及端口</label>
									 <div class="col-md-8">
										 <input type="text" name="image.dicomdata.hostAndPort" class="form-control">
										 <span class="help-block">联氪的ip及端口，如：120.77.183.7:7190</span>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">联氪影像所在目录</label>
									 <div class="col-md-8">
										 <input type="text" name="image.dicomdata.path" class="form-control" value="123456">
										 <span class="help-block">相对于联氪服务部署位置,影像所在的根目录，如：E:/dicomdata</span>
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>

					 <fieldset>
						 <legend style="font-size: 16px;">视频（海康）服务配置</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">IP</label>
									 <div class="col-md-8">
										 <input type="text" name="video.hk.ip" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">端口</label>
									 <div class="col-md-8">
										 <input type="text" name="video.hk.port" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">用户名</label>
									 <div class="col-md-8">
										 <input type="text" name="video.hk.username" class="form-control" value="admin">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">密码</label>
									 <div class="col-md-8">
										 <input type="text" name="video.hk.password" class="form-control" value="a1111111">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">录播视频存储目录</label>
									 <div class="col-md-8">
										 <input type="text" name="video.ftp.file.path" class="form-control" value="ftp_200807171">
										 <span class="help-block">ftp账号对应的目录(录播上传文件的目录)，如：ftp_200807171</span>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">海康视频共享地址</label>
									 <div class="col-md-8">
										 <input type="text" name="video.hk.shared.path" class="form-control">
										 <span class="help-block">海康视频硬件地址，如：\\\\192.168.0.219\\record\\ftp_200807171\\</span>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">视频共享映射目录</label>
									 <div class="col-md-8">
										 <input type="text" name="video.internet.shared.path" class="form-control">
										 <span class="help-block">海康视频文件存储目录挂载地址，如：Z:/ftp_200807171/</span>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">EasyNVR的IP</label>
									 <div class="col-md-8">
										 <input type="text" name="video.nvr.ip" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">EasyNVR端口</label>
									 <div class="col-md-8">
										 <input type="text" name="video.nvr.port" class="form-control">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">NVR回放视频地址</label>
									 <div class="col-md-8">
										 <input type="text" name="video.nvr.load.path" class="form-control">
										 <span class="help-block">NVR回放访问地址，如：http://192.168.0.219:10800/record/ftp_200807171/</span>
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>

					 <fieldset>
						 <legend style="font-size: 16px;">语音服务配置</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">百度语音APP_ID</label>
									 <div class="col-md-8">
										 <input type="text" name="speech.baiDuYY.APP_ID" class="form-control" value="14837655">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">百度语音API_KEY</label>
									 <div class="col-md-8">
										 <input type="text" name="speech.baiDuYY.API_KEY" class="form-control" value="WhaIHoIcc84GdRIqjUpo9moN">
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">SECRET_KEY</label>
									 <div class="col-md-8">
										 <input type="text" name="speech.baiDuYY.SECRET_KEY" class="form-control" value="1VSlfybrgk941zd6GGd4zKAworYvComy">
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>

					 <fieldset>
						 <legend style="font-size: 16px;">转码服务配置</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">转码服务地址</label>
									 <div class="col-md-8">
										 <input type="text" name="transcoding.os.url" class="form-control">
										 <span class="help-block">转码服务访问地址，如：http://192.168.0.226:9377</span>
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>

					 <fieldset>
						 <legend style="font-size: 16px;">文件存储服务配置</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">图片存储目录</label>
									 <div class="col-md-8">
										 <input type="text" name="storage.file.dir.path" class="form-control">
										 <span class="help-block">图片文件存储目录，如：D:/data/img/</span>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">默认图片路径</label>
									 <div class="col-md-8">
										 <input type="text" name="storage.file.default.img" class="form-control">
										 <span class="help-block">默认图片路径，如：D:/data/img/no-video.jpg</span>
									 </div>
								 </div>
							 </div>
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">默认头像地址</label>
									 <div class="col-md-8">
										 <input type="text" name="storage.user.headimage" class="form-control">
										 <span class="help-block">回复评论显示用户默认头像地址，如：http://192.168.0.219:10800/record/img/headImage.jpg</span>
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>

					 <fieldset>
						 <legend style="font-size: 16px;">其它配置</legend>
						 <div class="row">
							 <div class="col-md-6">
								 <div class="form-group">
									 <label class="col-md-4 control-label">是否隐藏敏感数据</label>
									 <div class="col-md-8">
										 <div class="radio-box">
											 <input type="radio" name="other.patutil.setting" value="true">
											 <label>隐藏</label>
										 </div>
										 <div class="radio-box">
											 <input type="radio" name="other.patutil.setting" value="false">
											 <label>不隐藏</label>
										 </div>
									 </div>
								 </div>
							 </div>
						 </div>
					 </fieldset>
				 </div>
			 </div>

			 <div class="save-form" style="display: table;margin: 0 auto">
				 <a class="btn btn-primary btn-setting btn_server_config_save" href="javascript:void(0)">保存设置</a>
				 <a class="btn btn-primary btn-setting btn_config_download disabled" href="javascript:void(0)">下载配置文件</a>

				 <span class ="div-hide" id="prjvConfigId" id-value="" />
				 <span class="div-hide" id="projectVersionId" id-value=""/>
			 </div>
		 </form>
	</div>
    <div th:include="include :: footer"></div>
	<script th:src="@{/ajax/libs/jquery-layout/jquery.layout-latest.js}"></script>
	<script th:src="@{/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js}"></script>
    <script th:inline="javascript">
        var prefix = ctx + "project/prjversionConfig";
        $("#product-version-setting-form").validate({
            rules:{
                "server.mysql.host":{required:true},
                "server.mysql.port":{required:true,digits:true},
                "server.mysql.dbname":{required:true},
                "server.mysql.db.username":{required:true},
                "server.mysql.db.password":{required:true},
                "server.redis.host":{required:true},
                "server.redis.port":{required:true,digits:true},
                "server.redis.password":{required:true},
                "apache.intranet.protocol":{required:true},
                "apache.intranet.host":{required:true},
                "apache.intranet.port":{required:true,digits:true},
                "apache.extranet.protocol":{required:true},
                "apache.extranet.host":{required:true},
                "apache.extranet.port":{required:true,digits:true},
                "dorcst.api.ip":{required:true},
                "dorcst.api.port":{required:true,digits:true},
                "meeting.client":{required:true},
                "meeting.domain":{required:true},
                "meeting.wsUrl":{required:true},
                "meeting.password":{required:true},
                "meeting.keyCode":{required:true},
                "meeting.maxUserCount":{required:true},
                "meeting.verifyMode":{required:true},
                "meeting.rootName":{required:true},
                "meeting.rootPWD":{required:true},
                "dorcst.sync.host":{required:true},
                "dorcst.sync.port":{required:true,digits:true},
                "image.hospital.ftp.address":{required:true},
                "image.hospital.ftp.port":{required:true,digits:true},
                "image.hospital.ftp.username":{required:true},
                "image.hospital.ftp.password":{required:true},
                "image.myftp.shared.path":{required:true},
                "image.dicomdata.path":{required:true},
                "image.dicomdata.hostAndPort":{required:true},
                "video.ftp.file.path":{required:true},
                "video.hk.ip":{required:true},
                "video.hk.port":{required:true,digits:true},
                "video.hk.username":{required:true},
                "video.hk.password":{required:true},
                "video.hk.shared.path":{required:true},
                "video.internet.shared.path":{required:true},
                "video.nvr.ip":{required:true},
                "video.nvr.port":{required:true,digits:true},
                "video.nvr.load.path":{required:true},
                "speech.baiDuYY.APP_ID":{required:true},
                "speech.baiDuYY.API_KEY":{required:true},
                "speech.baiDuYY.SECRET_KEY":{required:true},
                "transcoding.os.url":{required:true},
                "storage.file.dir.path":{required:true},
                "storage.file.default.img":{required:true},
                "storage.user.headimage":{required:true},
                "other.patutil.setting":{required:true},
            }
        });
        $(function() {
            $('body').layout({ west__size: 185 });
            queryProjectVersionTree();
        });

        //填充form表单
        function fillConfigForm(projectVersionId) {
            //若参数为空，则不添加
            if(typeof projectVersionId == "undefined" || projectVersionId == null || projectVersionId == ""){
                $.modal.alertError("请选择项目版本");
                return;
            }
			//从服务端获取此项目版本的配置信息
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/list",
                data : {
                    "projectVersionId": projectVersionId,
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    var form = $("#product-version-setting-form");
                    //填充表单前先重置
                    form[0].reset();
                    //填充表单
                    var pvList = data.rows;
                    if(pvList.length > 0){
                        //设置当前配置对象的id
                        var prjvConfigId = pvList[0].id;
                        $("#prjvConfigId").attr("id-value",prjvConfigId);
						var settingJsonStr = pvList[0].config;
                        var settingJsonObject = JSON.parse(settingJsonStr);
                        for (var i = 0; i < settingJsonObject.length; i++) {
                            var inputData = settingJsonObject[i];
							var name = inputData.name;
							var value = inputData.value;
							//赋值
                            var formFields = form.find("[name='"+name+"']");
                            formFields.each(function(index,e){
                                var formField = $(e);
                                if($.type(formField[0]) === "undefined"){
                                    //没找到指定name的表单
                                    console.log("can not find name:["+name+"] in form!");
                                } else {
                                    var fieldTagName = formField[0].tagName.toLowerCase();
                                    var inputType = formField.attr("type");
                                    // console.log("name:"+name+",tagName:"+fieldTagName+",type:"+inputType);
                                    //普通输入
                                    if(fieldTagName == "input"){
                                        //单选
                                        if(inputType == "radio"){
                                            //设置当前选择
											if(formField.val()==value){
                                                formField.iCheck('check');
                                            }else{
                                                formField.iCheck('uncheck');
											}
                                            // console.log("-----name:"+formField.prop('name')+",value:"+formField.val()+",checked:"+formField.prop('checked'));
                                        } else if(inputType=='checkbox'){//复选
                                            var arr = value.split(',');
                                            for(var i =0;i<arr.length;i++){
                                                if(formField.val()==arr[i]){
                                                    formField.prop('checked',true);
                                                    break;
                                                }
                                            }
                                        }else {//其它
                                            formField.val(value);
                                        }
                                    } else if(fieldTagName == "select"){
                                        formField.val(value);
                                    } else if(fieldTagName == "textarea"){
                                        formField.val(value);
                                    } else {
                                        formField.val(value);
                                    }
                                }
                            });
                        }

                        //赋值完毕后，启用下载按钮
						$(".btn_config_download").removeClass("disabled");
                    }
                }
            });
		}

        function queryProjectVersionTree()
        {
            var url = ctx + "project/projectVersion/treeData";
            var options = {
                url: url,
                expandLevel: 2,
                onClick : zOnClick
            };
            $.tree.init(options);

            function zOnClick(event, treeId, treeNode) {
                //设置项目版本id
                // $("input[name='projectVersionId']").val(treeNode.id);
                $("#projectVersionId").attr("id-value",treeNode.id);
                fillConfigForm(treeNode.id);
            }
        }

        $('#btnExpand').click(function() {
            $._tree.expandAll(true);
            $(this).hide();
            $('#btnCollapse').show();
        });

        $('#btnCollapse').click(function() {
            $._tree.expandAll(false);
            $(this).hide();
            $('#btnExpand').show();
        });

        $('#btnRefresh').click(function() {
            queryProjectVersionTree();
        });

        /*项目版本管理页面*/
        function toProjectVersion() {
            var url = ctx + "project/productVersion";
            createMenuItem(url, "项目版本");
        }

        //保存配置信息
        $("body").on("click","a.btn_server_config_save",function () {
            var projectVersionId = $("#projectVersionId").attr("id-value");
            var prjvConfigId = $("#prjvConfigId").attr("id-value");
            // var projectVersionId = $("input[name='projectVersionId']").val();
            // var prjvConfigId = $("input[name='prjvConfigId']").val();
            if(typeof projectVersionId == "undefined" || projectVersionId == null || projectVersionId == ""){
                $.modal.alertError("请选择项目版本");
                return;
            }
            //检验成功后进行保存
            if ($.validate.form()) {
                var currentSetting = $("#product-version-setting-form").serializeArray();
                var currentSettingStr = JSON.stringify(currentSetting);
                //从服务端获取此项目版本的配置信息
                $.ajax({
                    cache : true,
                    type : "POST",
                    url : prefix + "/edit",
                    data : {
                        "id": prjvConfigId,
                        "projectVersionId": projectVersionId,
                        "config": currentSettingStr,
                    },
                    async : false,
                    error : function(request) {
                        $.modal.alertError("系统错误");
                    },
                    success : function(data) {
                        if(data.code == "0"){
                            $.modal.alertSuccess("保存成功");
                        }else{
                            $.modal.alertError("保存失败");
						}
                    }
                });
			}
        })

		//下载配置内容
        $("body").on("click","a.btn_config_download",function () {
            var prjvConfigId = $("#prjvConfigId").attr("id-value");
            //若参数为空，则不添加
            if(typeof prjvConfigId == "undefined" || prjvConfigId == null || prjvConfigId == ""){
                $.modal.alertError("请先保存配置");
                return;
            }
            //下载
            var context = getContextPath();
            var downloadUrl = context + "/file/download_prop_file";
            downloadUrl = downloadUrl + "?prjvConfigId="+prjvConfigId;
            window.open(downloadUrl);
        })
    </script>
</body>
</html>